package com.srd.phone.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.shengrongdai.srd.R;
import com.srd.phone.bean.ChargeRecord;
import com.srd.phone.utils.views.ViewHolder;

import java.util.ArrayList;
import java.util.List;

public class RechargeRecordAdapter extends BaseAdapter {

    private Context context;
    private List<ChargeRecord> list = new ArrayList<ChargeRecord>(10);

    public RechargeRecordAdapter(Context context, List<ChargeRecord> list0) {
        this.context = context;
        list = list0;
    }

    public void setData(List<ChargeRecord> list0) {
        list = list0;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public ChargeRecord getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        ViewHolder viewHolder =  ViewHolder.get(context, view, parent, R.layout.item_recharge_record, position);

        ChargeRecord item = getItem(position);

        TextView tv_money = viewHolder.getView(R.id.tv_money);
        tv_money.setText(item.money + "元");

        TextView tv_date = viewHolder.getView(R.id.tv_date);
        tv_date.setText(item.ctime);

        TextView tv_state = viewHolder.getView(R.id.tv_state);
        tv_state.setText(item.cstatem);

        TextView tv_bank = viewHolder.getView(R.id.tv_bank);
        tv_bank.setText(item.banknm);

        return viewHolder.getConvertView();
    }


}
